﻿package com.petermacko.utils.system {
	import flash.system.System;
	import flash.utils.setInterval;

	public class MemoryChecker
	{
		private var id:uint; //checkMemoryIntervalID
		private var sw:Boolean; //showWarning
		private var wm:uint; //warningMemory
		private var am:uint; //abortMemory

		public function MemoryChecker() {
			id = setInterval(checkMemoryUsage,1000);
			sw = true;
			wm = 1000*1000*500;
			am = 1000*1000*625;
		}
		private function checkMemoryUsage():void {
			if(System.totalMemory>wm&&sw) {
				sw = false;
			} else if(System.totalMemory>am) {
				trace("end");
			}
		}
	}
}